package com.sonicvision.resourcetracker.employee;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.springframework.stereotype.Repository;

import com.sonicvision.resourcetracker.exceptions.DAOException;

@Repository
public class EmployeeDAOJPAImpl implements EmployeeDAO {

	@PersistenceContext(unitName = "resourcetracker")
	private EntityManager em;

	@Override
	public void addEmployee(Employee employee) throws DAOException {

		em.persist(employee);
	}

	@Override
	public List<Employee> getListOfEmployees() throws DAOException {
		Query query = em.createQuery("from Employee");
		List<Employee> listOfEmployees = query.getResultList();

		return listOfEmployees;
	}

	@Override
	public Employee findByPrimaryKey(int employeeId) throws DAOException {
		Employee employee = em.find(Employee.class, employeeId);
		return employee;

	}

	@Override
	public void updateEmployee(Employee employee) throws DAOException {

	}

	@Override
	public void deleteEmployee(int employeeId) throws DAOException {

	}

}
